<template>
  <view>
    <view class="w100 pt-16 pl-24 pr-24">
      <view class="p-all-30 w100 bgff br-10 rowscl mb-20">
        <view class="w100 rowsb rowsm mb-16">
          <view class="fs-30 col333 fw-b" v-if="index == 0">劳动项目：{{data.name}}</view>
          <view class="fs-30 col333 fw-b" v-else>劳动项目：{{index == 1 ? '社会公益劳动' : index == 2 ? '劳动成果' : data.name ? data.name :'劳动总结报告'}}</view>
          <view class="pl-20 pr-20 h-50 br-25 rowsc rowsm fs-24" style="border: 2rpx solid #FF9934;color: #FF9934;" v-if="data.markNumber">{{data.markNumber}}</view>
           <view class="pl-20 pr-20 h-50 br-25 rowsc rowsm fs-24" style="border: 2rpx solid #FF9934;color: #FF9934;" v-if="data.status == '1'">未审批</view> 
          <view class="pl-20 pr-20 h-50 br-25 rowsc rowsm fs-24" style="border: 2rpx solid #FF6560;color: #FF6560;" v-else-if="data.status == '3'">已驳回</view> 
        </view>
         <view class="w100 rowsb rowsm" v-if="index == 0">
            <view class="fs-26 col888 mb-20">分类:基础劳动/{{data.typeName}}</view>
            <view class="w-126 h-50 br-25 rowsc rowsm fs-24" style="border: 2rpx solid #FF9934;color: #FF9934;" v-if="data.status == 2">{{data.dfCount}}积分</view>
         </view>
         
        <view class="fs-26 col888 mb-20" v-else>分类：{{index == 1 ? '社会公益劳动' : index == 2 ? '劳动成果' : '劳动总结报告'}}</view>
        <view class="fs-26 col888 mb-20" v-if="data.bgTime">时间:{{data.bgTime}}</view>
        <view class="fs-26 col888 mb-20" v-if="data.dwName">主办单位:{{data.dwName}}</view>
        <view class="fs-26 col888 mb-20" v-if="data.startTime && data.stopTime">劳动时间:{{data.startTime}}至{{data.stopTime}}</view>
        <view class="fs-26 col888 mb-20" v-if="data.position">劳动地点:{{data.position}}</view>
        <view class="fs-26 col888 mb-20" v-if="data.jbName">级别:{{data.jbName}}</view>
        <view class="fs-26 col888 mb-20" v-if="data.djName">等级:{{data.djName}}</view>
        <view class="fs-26 col888 mb-20" v-if="data.wcName">位次:{{data.wcName}}</view>
        <view class="fs-26 col888 mb-20" v-if="data.proLdUserList && data.proLdUserList[0]">负责人:{{data.proLdUserList[0].stName}}</view>
        <view class="fs-26 col888 mb-20">提交时间:{{data.createTime}}</view>
        <view class="fs-26 col888 mb-20" v-if="data.status == 2 || data.status == 3">审批时间:{{data.opTime?data.opTime:''}}</view>
      </view>
      
      <view class="p-all-30 w100 bgff br-10 mb-20">
        <view class="fs-30 col333 fw-b mb-20">劳动过程说明</view>
        <view class="fs-26 col888">{{data.content}}</view>
      </view>
      
      <view class="p-all-30 w100 bgff br-10 mb-20">
        <view class="fs-30 col333 fw-b mb-20">附件</view>
        <!-- <view class="fs-26 col888">劳动过程</view> -->
        <view v-for="item in data.proFileList" :key="item.id">
          <view class="rowsb">
            <image :src="item.file" class="w-200 h-200 br-20 " v-if="item.fileType == 'image'" mode="aspectFill" @click="openImg(item.file)"></image>
          </view>
        <video :src="item.file" class="w-200 h-200 br-20" v-if="item.fileType == 'video'"></video>
        <view class="w100 h-140 br-10 rows rowsm pl-40 mt-20" style="background-color: #F7F6FA;" v-if="item.fileType == 'file'" @click="openFile(item.file)">
          <image src="/static/file.png" class="w-60 h-60 mr-20" mode=""></image>
          <view class="fs-28 col888 w100 one_overflow">{{item.fileName}}</view>
        </view>
        </view>
       
      </view>
      
      <view class="p-all-30 w100 bgff br-10 mb-20" v-if="data.markName">
        <view class="fs-30 col333 fw-b mb-20">{{data.status == 3 ? '驳回详情' : '评语'}}</view>
        <view class="fs-26 col888">{{data.markName}}</view>
      </view>
    </view>
    
    <view class="w100 h-140"></view>
    
   <view class="w100 rowsc rowsm fixed" style="bottom: 40rpx;">
      <view class="w-702 h-84 br-42 rowsc rowsm colfff fw-b" style="background: linear-gradient(to bottom,#4897FF,#4878FF);" v-if="data.status == 3" @click="reSubmit()">重新填写</view>
    </view>
    <view class="w100 rowsc rowsm fixed" style="bottom: 40rpx;">
      <view class="w-702 h-84 br-42 rowsc rowsm colfff fw-b" style="background: linear-gradient(to bottom,#4897FF,#4878FF);" v-if="data.status == 1" @click="reSubmit()">修改</view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        id:'',
        data:{},
        index:''
      };
    },
    onLoad(e) {
      this.id = e.id
      console.log('eeee',e)
      if(e.index == '-1'){
        if(e.ldType == '1'){
          this.index = 0
        }else if(e.ldType == '2'){
          this.index = 1
        }else if(e.ldType == '4'){
          this.index = 3
        }else if(e.ldType == '3'){
          this.index = 2
        }
        // this.index = e.ldType
      }else if(e.index == '3'){
        this.index = 1
      }else if(e.index == '1'){
        this.index = 3
      }else{
        this.index = e.index
      }
      this.getInfo()
    },
    methods:{
      reSubmit(){
        if(this.index == 0) {
          let i = this.data.type
          let title = this.data.typeName
          let id = this.data.id
          if(i == 1 || i == 2 || i == 3 || i == 9 || i == 10 || i == 11) {
            this.$tools.goNext(`/pagesCopy/submitWork/weekWork?type=${i}&title=${title}&id=${id}`)
          }
          if(i == 4) {
            this.$tools.goNext(`/pagesCopy/submitWork/workSavour?type=${i}&title=${title}&id=${id}`)
          }
          if(i == 5) {
            this.$tools.goNext(`/pagesCopy/submitWork/university?type=${i}&title=${title}&id=${id}`)
          }
          if(i == 6) {
            this.$tools.goNext(`/pagesCopy/submitWork/internet?type=${i}&title=${title}&id=${id}`)
          }
          if(i == 7) {
            this.$tools.goNext(`/pagesCopy/submitWork/speech?type=${i}&title=${title}&id=${id}`)
          }
          if(i == 8) {
            this.$tools.goNext(`/pagesCopy/submitWork/example?type=${i}&title=${title}&id=${id}`)
          }
        }
        if(this.index == 1) {
          let id = this.data.id
          this.$tools.goNext(`/pages/index/sumUp?id=${id}`)
        }
        if(this.index == 2) {
          let id = this.data.id
          this.$tools.goNext(`/pages/index/gain?id=${id}`)
        }
        if(this.index == 3) {
          let id = this.data.id
          this.$tools.goNext(`/pages/index/publicGood?id=${id}`)
        }
      },
      getInfo(){
        if(this.index == 0) {//基础劳动
          this.$tools.axiosFromToken('POST','prold/getById',{id:this.id},'加载中').then(res => {
            if(res.code != 200) return this.$tools.showtt(res.msg)
            let {data} = res
            if(data.proFileList.length > 0){
                data.proFileList.forEach(item =>{
                  item.file = this.$tools.avatarUrl + item.file
                })
              }
             
            this.data = data
            uni.setNavigationBarTitle({
              title:data.name
            })
          })
        }else if(this.index == 1){//社会公益劳动
          this.$tools.axiosFromToken('POST','proldgy/getById',{id:this.id},'加载中').then(res => {
            if(res.code != 200) return this.$tools.showtt(res.msg)
            let {data} = res
            if(data.proFileList.length > 0){
              data.proFileList.forEach(item =>{
                item.file = this.$tools.avatarUrl + item.file
              })
            }
            this.data = data
            uni.setNavigationBarTitle({
              title:'社会公益劳动'
            })
          })
        }else if(this.index == 2){//劳动成果
          this.$tools.axiosFromToken('POST','proldcg/getById',{id:this.id},'加载中').then(res => {
            if(res.code != 200) return this.$tools.showtt(res.msg)
            let {data} = res
            if(data.proFileList.length > 0){
              data.proFileList.forEach(item =>{
                item.file = this.$tools.avatarUrl + item.file
              })
            }
            this.data = data
            uni.setNavigationBarTitle({
              title:'劳动成果'
            })
          })
        }else if(this.index == 3){//劳动总结报告
          this.$tools.axiosFromToken('POST','proldzj/getById',{id:this.id},'加载中').then(res => {
            if(res.code != 200) return this.$tools.showtt(res.msg)
            let {data} = res
          if(data.proFileList.length > 0){
              data.proFileList.forEach(item =>{
                item.file = this.$tools.avatarUrl + item.file
              })
            }
            this.data = data
            uni.setNavigationBarTitle({
              title:'劳动总结报告'
            })
          })
        }
      },
      openImg(url){
        uni.previewImage({
          urls:[url]
        })
      },
      openFile(url){
        uni.downloadFile({
          url:url,
          success(res) {
            uni.openDocument({
              filePath:res.tempFilePath,
              showMenu:true,
              complete(msg) {
                console.log(msg)
              }
            })
          }
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
.rowsb {
 
}
</style>
